import { createRouter, createWebHashHistory, RouterOptions } from 'vue-router'

export const routes = [{
  name: 'home',
  path: '/',
  meta: {
    title: '首页'
  },
  component: () => import('@/views/home.vue')
}, {
  name: 'AppLink',
  path: '/AppLink',
  meta: {
    title: 'AppLink 组件'
  },
  component: () => import('@/packages/AppLink/docs/README.md'),
}, {
  name: 'AsyncList',
  path: '/AsyncList',
  meta: {
    title: 'AsyncList 组件'
  },
  component: () => import('@/packages/AsyncList/docs/README.md'),
}, {
  name: 'Avatar',
  path: '/Avatar',
  meta: {
    title: 'Avatar 组件'
  },
  component: () => import('@/packages/Avatar/docs/README.md'),
}, {
  name: 'Cropper',
  path: '/Cropper',
  meta: {
    title: 'Cropper 组件'
  },
  component: () => import('@/packages/Cropper/docs/README.md'),
}, {
  name: 'ImportDialog',
  path: '/ImportDialog',
  meta: {
    title: 'ImportDialog 组件'
  },
  component: () => import('@/packages/ImportDialog/docs/README.md'),
}, {
  name: 'page',
  path: '/page',
  meta: {
    title: 'page 组件'
  },
  component: () => import('@/packages/Page/docs/README.md'),
}, {
  name: 'SlideVerify',
  path: '/SlideVerify',
  meta: {
    title: 'SlideVerify 组件'
  },
  component: () => import('@/packages/SlideVerify/docs/README.md'),
}, {
  name: 'State',
  path: '/State',
  meta: {
    title: 'State 组件'
  },
  component: () => import('@/packages/State/docs/README.md'),
}, {
  name: 'Svg',
  path: '/Svg',
  meta: {
    title: 'Svg 组件'
  },
  component: () => import('@/packages/Svg/docs/README.md'),
}, {
  name: 'Table',
  path: '/Table',
  meta: {
    title: 'Table 组件'
  },
  component: () => import('@/packages/Table/docs/README.md'),
}, {
  name: 'Tel',
  path: '/Tel',
  meta: {
    title: 'Tel 组件'
  },
  component: () => import('@/packages/Tel/docs/README.md'),
}, {
  name: 'Tooltip',
  path: '/Tooltip',
  meta: {
    title: 'Tooltip 组件'
  },
  component: () => import('@/packages/Tooltip/docs/README.md'),
}, {
  name: 'TreeNode',
  path: '/TreeNode',
  meta: {
    title: 'TreeNode 组件'
  },
  component: () => import('@/packages/TreeNode/docs/README.md'),
}];

const routerConfig = {
  history: createWebHashHistory(),
  routes,
  scrollBehavior(to: any, from: any) {
    if (to.path !== from.path) {
      return { top: 0 };
    }
  },
};

const router = createRouter(routerConfig as RouterOptions);

export default router;